﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Rbac.Services.Menus;
using Rbac.Services.Menus.Dto;
using Microsoft.AspNetCore.Authorization;

namespace RbacSystem.Controllers
{
    [Route("/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class MenuController : ControllerBase
    {
        private readonly IMenuService service;

        public MenuController(IMenuService service)
        {
            this.service = service;
        }

        [HttpPost]
        public IActionResult Create(CreateMenuDto dto)
        {
            return Ok(service.Create(dto));
        }

        [HttpPost]
        public IActionResult Update(UpdateMenuDto dto)
        {
            return Ok(service.Update(dto));
        }

        [HttpGet]
        public IActionResult Query()
        {
            return new JsonResult(service.Query());
        }

        [HttpGet]
        public IActionResult Delete(int MenuId)
        {
            return Ok(service.Delete(MenuId));
        }
    }
}
